package com.jxlc.common.core.domain.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jxlc.common.core.domain.entity.SysUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Set;

/**
 * 登录用户身份权限
 *
 * @author lc
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class LoginUser extends BaseLoginUser {

    private static final long serialVersionUID = 1L;

    /**
     * 浏览器类型
     */
    private String browser;

    /**
     * 操作系统
     */
    private String os;

    /**
     * 权限列表
     */
    private Set<String> permissions;

    /**
     * 角色列表
     */
    private Set<String> roles;

    /**
     * 用户信息
     */
    private SysUser user;

    public LoginUser(SysUser user, Set<String> permissions)
    {
        this.user = user;
        this.permissions = permissions;
        super.setLoginTime(System.currentTimeMillis());
    }

    @JsonIgnore
    public String getPassword()
    {
        return user.getPassword();
    }

    public Long getUserId() {
        return this.user.getUserId();
    }

    public String getUsername() {
        return this.user.getUserName();
    }
}
